package com.ht.system.api;

import com.ht.common.core.domain.LoginUser;
import com.ht.common.core.web.domain.AjaxResult;
import com.ht.system.api.dto.LoginBodyDto;
import com.ht.system.api.dto.SysUserDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import com.ht.common.core.constant.SecurityConstants;
import com.ht.common.core.constant.ServiceNameConstants;
import com.ht.common.core.domain.R;
import com.ht.system.api.factory.RemoteUserFallbackFactory;

/**
 * 用户服务
 *
 * @author ruoyi
 */
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService {
    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @param source   请求来源
     * @return 结果
     */
    @GetMapping("/user/info/{username}")
    public R<LoginUser> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PostMapping("/user/wx/register")
    public R<String> wxRegister(@RequestBody SysUserDto sysUserDto, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 微信小程序登录
     *
     * @param loginBodyDto
     * @param source
     * @return
     */
    @PostMapping("/wxLogin")
    R<AjaxResult> wxLogin(@RequestBody LoginBodyDto loginBodyDto, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/user/wxUserInfo")
    R<SysUserDto> getUserInfoByWx(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

}
